Philosophy Data Story Liang Hu 01/23/2022
What is the most frequency word the communism philosopher and capitalism philosophers use in sentences ?
What is the characteristic of Communism philosophers and capitalism philosophers ?
What are the possible topics that Communism philosophers and Capitalism philosophers will tend to talk about ?
Communism and capitalism are two different economic and political ideologies that have had a significant impact on the development of modern society. Both ideologies have their roots in philosophy, and they have been the subject of much debate and discussion throughout history.
Communism, as a political and economic system, is based on the idea that all individuals should have equal access to the means of production, and that the state should control and own these means. This system is intended to eliminate class distinctions and create a society where everyone has equal opportunity and access to resources. The philosopher Karl Marx is considered the father of communism, and his ideas have been influential in the development of communist societies throughout the world.
Capitalism, on the other hand, is an economic system in which private individuals and businesses own the means of production, and the economy is driven by the profit motive. The state plays a limited role in the economy, and individuals are free to own property, start businesses, and compete in the market. The philosopher Adam Smith is considered the father of capitalism, and his ideas about laissez-faire economics have been influential in the development of capitalist societies throughout the world.
library(magrittr) # needs to be run every time you start R and want to use %>%
library(dplyr) # alternatively, this also loads %>%
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyverse)
## ── Attaching packages
## ───────────────────────────────────────
## tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0 ✔ purrr 1.0.1
## ✔ tibble 3.1.8 ✔ stringr 1.5.0
## ✔ tidyr 1.2.1 ✔ forcats 0.5.2
## ✔ readr 2.1.3
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ tidyr::extract() masks magrittr::extract()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ✖ purrr::set_names() masks magrittr::set_names()
library(tidytext)
library(ggplot2)
library(dplyr)
library(tidyr)
library(wordcloud)
## Loading required package: RColorBrewer
library(tm)
## Loading required package: NLP
##
## Attaching package: 'NLP'
##
## The following object is masked from 'package:ggplot2':
##
## annotate
library(topicmodels)
library(RColorBrewer)
d=read.csv("../data/philosophy_data.csv")
capitalism = subset(d, school == "capitalism")
communism =subset(d, school=="communism")
tidy_communism <- communism %>%
unnest_tokens(word, sentence_str) %>%
anti_join(stop_words) %>%
count(word)%>%
filter(n >500)%>%
arrange(desc(n))
## Joining, by = "word"
#write.csv(tidy_communism, "../output/com_word_freq.csv", row.names=FALSE)
tidy_communism
hist(tidy_communism$n)
tidy_capitalism <- capitalism %>%
unnest_tokens(word, sentence_str) %>%
anti_join(stop_words) %>%
count(word)%>%
filter(n >500)%>%
arrange(desc(n))
## Joining, by = "word"
# write.csv(tidy_capitalism, "../output/cap_word_freq.csv", row.names=FALSE)
tidy_capitalism
hist(tidy_capitalism$n)
The most commonly used words in discussions about communism are “price”, “money” and “labor” that focus on the ordinary workers. The top 10 words chosen by people discussing capitalism may vary, but they are likely to focus on business-related concepts which is based on private ownership of the means of production and the creation of goods and services for profit
The following two work clouds can show different concerns that two ideologies. We can understand although there are two total different ideologies in the society. They still have relative high similar words. The most common words for communism are labor and capital. On the other hand, capitalism philosophers tend to use the word like price and money which answer the first question. This may indicate that despite the fundamental differences, both ideologies share some common concerns, such as economy, society, and government. Additionally, it’s also important to note that language used to discuss these ideologies may be similar, but the context and perspective can change the meaning of the words.
wordcloud(words =tidy_communism$word, freq=tidy_communism$n, max.words =100,
colors=brewer.pal(8, "Dark2"))
wordcloud(words =tidy_capitalism$word, freq=tidy_capitalism$n, max.words =100,
colors=brewer.pal(8, "Dark2"))
## Warning in wordcloud(words = tidy_capitalism$word, freq = tidy_capitalism$n, :
## price could not be fit on page. It will not be plotted.
all_capitalism <- capitalism %>%
unnest_tokens(word, sentence_str) %>%
anti_join(stop_words) %>%
count(word)%>%
arrange(desc(n))
## Joining, by = "word"
all_communism <- communism %>%
unnest_tokens(word, sentence_str) %>%
anti_join(stop_words) %>%
count(word)%>%
arrange(desc(n))
## Joining, by = "word"
library("textdata")
sentiments_capitalism= all_capitalism %>%
inner_join(get_sentiments("nrc")) %>%
filter(sentiment %in% c("anticipation", "joy", "surprise", "trust",
"anger", "disgust", "fear", "sadness" ))
## Joining, by = "word"
new2=sentiments_capitalism %>%
count(sentiment) %>%
# Arrange the sentiment counts in descending order
arrange(desc(n))
sentiments_capitalism %>%
group_by(sentiment) %>%
# Take the top 10 words for each sentiment
top_n(10, n) %>%
ungroup() %>%
mutate(word = reorder(word, n)) %>%
ggplot(aes(word,n, fill=sentiment, label=n )) +
geom_bar(stat="identity") +
coord_flip()
sentiments_capitalism %>%
group_by(sentiment) %>%
# Take the top 10 words for each sentiment
top_n(10, n) %>%
ungroup() %>%
mutate(word = reorder(word, n)) %>%
# Set up the plot with aes()
ggplot(aes(word,n, fill=sentiment)) +
geom_col(show.legend = FALSE) +
facet_wrap(~ sentiment, scales = "free") +
coord_flip()
col.use=c("darkgoldenrod1", "darkgoldenrod2", "darkgoldenrod3", "darkgoldenrod4",
"red2", "chartreuse3", "blueviolet","dodgerblue3")
barplot(new2$n, las=2, horiz=T, col=col.use[order(new2$n)], names.arg=new2$sentiment, main="capitalism philosophers")
sentiments_capitalism %>%
count(sentiment) %>%
# Arrange the sentiment counts in descending order
arrange(desc(n))
sentiments_communism= all_communism %>%
inner_join(get_sentiments("nrc")) %>%
filter(sentiment %in% c("anticipation", "joy", "surprise", "trust",
"anger", "disgust", "fear", "sadness" ))
## Joining, by = "word"
new1 = sentiments_communism %>%
count(sentiment) %>%
# Arrange the sentiment counts in descending order
arrange(desc(n))
new1
sentiments_communism %>%
group_by(sentiment) %>%
# Take the top 10 words for each sentiment
top_n(10, n) %>%
ungroup() %>%
mutate(word = reorder(word, n)) %>%
ggplot(aes(word,n, fill=sentiment, label=n )) +
geom_bar(stat="identity") +
coord_flip()
sentiments_communism %>%
group_by(sentiment) %>%
# Take the top 10 words for each sentiment
top_n(10, n) %>%
ungroup() %>%
mutate(word = reorder(word, n)) %>%
# Set up the plot with aes()
ggplot(aes(word,n, fill=sentiment)) +
geom_col(show.legend = FALSE) +
facet_wrap(~ sentiment, scales = "free") +
coord_flip()
col.use=c("darkgoldenrod1", "darkgoldenrod2", "darkgoldenrod3", "darkgoldenrod4",
"red2", "chartreuse3", "blueviolet","dodgerblue3")
barplot(new1$n, las=2, horiz=T, col=col.use[order(new1$n)], names.arg=new1$sentiment, main="communism philosophers")
sentiments_communism %>%
group_by(sentiment) %>%
# Take the top 10 words for each sentiment
top_n(10, n) %>%
ungroup() %>%
mutate(word = reorder(word, n)) %>%
# Set up the plot with aes()
ggplot(aes(word,n, fill=sentiment)) +
geom_col(show.legend = FALSE) +
facet_wrap(~ sentiment, scales = "free") +
coord_flip()
According to the emotion assessment, capitalism philosophers in general have less surprise, less trust, less disgust in their sentences. The similarity are their opinion towards happy and sadness. The mainly differences are the perspective of disgust. Communism philosophers have anger on slavery and death. In comparison, capitalism philosophers tend to have anger on abundance or prohibited the words that shows low profit. Also, capitalism philosopher have less trust and less surprise toward the public. These characteristic reflect their personalities are more calm and peace.
library("reshape2")
##
## Attaching package: 'reshape2'
## The following object is masked from 'package:tidyr':
##
## smiths
communism = subset(d, author == "Marx")
capitalism =subset(d, author=="Smith")
tidy_communism <- communism %>%
unnest_tokens(word, sentence_str) %>%
anti_join(stop_words)
## Joining, by = "word"
dtm_communism = tidy_communism %>%
count(word, author) %>%
# Cast the word counts into a DTM
cast_dtm(author, word, n)
tidy_capitalism <- capitalism %>%
unnest_tokens(word, sentence_str) %>%
anti_join(stop_words)
## Joining, by = "word"
dtm_capitalism = tidy_capitalism%>%
count(word, author) %>%
# Cast the word counts into a DTM
cast_dtm(author, word, n)
burnin <- 4000
iter <- 2000
thin <- 500
seed <-list(2003,5,63,100001,765)
nstart <- 5
best <- TRUE
#Number of topics
k <- 7
#Run LDA using Gibbs sampling
ldaOut <-LDA(dtm_capitalism, k, method="Gibbs", control=list(nstart=nstart,
seed = seed, best=best,
burnin = burnin, iter = iter,
thin=thin))
#write out results
#docs to topics
ldaOut.topics <- as.matrix(topics(ldaOut))
table(c(1:k, ldaOut.topics))
##
## 1 2 3 4 5 6 7
## 1 1 1 1 1 1 2
ldaOut.topics
## [,1]
## Smith 7
terms.beta=ldaOut@beta
terms.beta=scale(terms.beta)
topics.terms=NULL
for(i in 1:k){
topics.terms=rbind(topics.terms, ldaOut@terms[order(terms.beta[i,], decreasing = TRUE)[1:7]])
}
topics.terms
## [,1] [,2] [,3] [,4] [,5]
## [1,] "accumulating" "apply" "restrains" "punishment" "discounted"
## [2,] "troublesome" "chief" "growing" "succeeded" "metal"
## [3,] "shape" "demands" "accurate" "attended" "procured"
## [4,] "teach" "extreme" "trader" "tracts" "switzerland"
## [5,] "authors" "idleness" "seamen" "shepherd" "fields"
## [6,] "barter" "views" "attend" "birds" "prevailed"
## [7,] "funds" "demand" "magistrates" "country" "rest"
## [,6] [,7]
## [1,] "potosi" "justly"
## [2,] "habitation" "mill"
## [3,] "increase" "amount"
## [4,] "deeds" "occupation"
## [5,] "remaining" "bay"
## [6,] "plato" "play"
## [7,] "profit" "law"
burnin <- 4000
iter <- 2000
thin <- 500
seed <-list(2003,5,63,100001,765)
nstart <- 5
best <- TRUE
#Number of topics
k <- 7
#Run LDA using Gibbs sampling
ldaOut <-LDA(dtm_communism, k, method="Gibbs", control=list(nstart=nstart,
seed = seed, best=best,
burnin = burnin, iter = iter,
thin=thin))
#write out results
#docs to topics
ldaOut.topics <- as.matrix(topics(ldaOut))
table(c(1:k, ldaOut.topics))
##
## 1 2 3 4 5 6 7
## 2 1 1 1 1 1 1
ldaOut.topics
## [,1]
## Marx 1
terms.beta=ldaOut@beta
terms.beta=scale(terms.beta)
topics.terms=NULL
for(i in 1:k){
topics.terms=rbind(topics.terms, ldaOut@terms[order(terms.beta[i,], decreasing = TRUE)[1:7]])
}
topics.terms
## [,1] [,2] [,3] [,4] [,5]
## [1,] "political" "subsistence" "shillings" "laws" "scale"
## [2,] "fourier" "declare" "issued" "banking" "contractants"
## [3,] "della" "aptly" "italian" "lawyers" "finger"
## [4,] "crystal" "mistake" "sordid" "channel" "opiates"
## [5,] "defective" "northamptonshire" "check" "arisen" "confidence"
## [6,] "increase" "unpaid" "elementary" "strength" "malthus"
## [7,] "supposition" "alludes" "debtors" "gradation" "satisfy"
## [,6] [,7]
## [1,] "definite" "carried"
## [2,] "harris" "lucky"
## [3,] "journals" "diodorus"
## [4,] "syst" "cleaning"
## [5,] "perturbations" "pursue"
## [6,] "cloth" "lost"
## [7,] "notion" "confounds"
According to the LDA analysis that learn in the class, the representation of Communism philosopher Marx will tend to say about why the workers don’t have enough payment all the time. Some The representation of Capitalism philosophers, Smith will argue that we need to build the country. There are overwhelming demanding that the labor need to do. Also, He believed that the labor market, when left to its own devices, will adjust itself to balance supply and demand.
What is the most frequency word the communism philosopher and capitalism philosophers use in sentences ?
What is the characteristic of Communism philosophers and capitalism philosophers ?
What are the possible topics that Communism philosophers and Capitalism philosophers will tend to talk about ?
The most common used words for communism philosopher are “labor”, “capital”, and production. Also, the most frequency words that capitalism philosopher used are “price”, “money”, and “labor”
The characteristic of capitalism philosophers are innovative, leading to greater efficiency, and calm. In comparison, communism philosophers tend to have anger on abundance or prohibited the words that shows low profit.
Marx may asked Smith to focus on labor life quality. Then, Smith will argue that efficiency on production and principle of a free market is the core topic. They may argue about society and the public in the following topics.